<?php

namespace app\service\admin;

use app\service\base\BaseLogic;

class RolePurviewLogic extends BaseLogic
{
    public function getListByRoleId($roleId)
    {
        $arrWhere = [];
        $arrWhere['admin_role_id'] = $roleId;
        return (new RolePurviewModel())->getAll($arrWhere);
    }

    public function delByIds($roleId, $arrIds)
    {
        $arrWhere = [];
        $arrWhere[] = ['admin_role_id', '=', $roleId];
        $arrWhere[] = ['admin_purview_id', 'in', $arrIds];
        return (new RolePurviewModel())->del($arrWhere);
    }

    public function addMulti($arrData)
    {
        return (new RolePurviewModel())->addMulti($arrData);
    }

    public function check($url, $roleId)
    {
        $arrData = (new RolePurviewModel())->getRowJoinPurview($url, $roleId, 'RP.id');
        return empty($arrData) ? false : true;
    }
}